package models

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

// FileCategory 文件上传表结构
type FileCategory struct {
	Id           int    `json:"id" orm:"column(id) bigint pk;auto"`
	CategoryCode string `json:"categoryCode" orm:"column(category_code) size(20)"`
	CategoryName string `json:"categoryName" orm:"column(category_name) size(100)"`
	Backimage    string `json:"backImage" orm:"column(backimage) size(300)"`
	Status       int    `json:"status" orm:"column(status)"`
}

func (f *FileCategory) TableName() string {
	return "category"
}

// 图片分页查询
func (f *FileCategory) GetList() ([]FileCategory, error) {
	getOrm := orm.NewOrm()
	var res = make([]FileCategory, 0)
	qs := getOrm.QueryTable(f.TableName())
	_, err := qs.OrderBy("category_code").Filter("status", 0).All(&res)
	beego.Info("查找成功")
	return res, err
}

func NewFileCategory() *FileCategory {
	return &FileCategory{}
}
